package com.steven.io;

import java.io.IOException;
import java.io.InputStream;

public class MyBufferedInputStream {
	private InputStream in ;
	private static int count;
	private int pos;
	private byte[] buf= new byte[1024];
	
	public  MyBufferedInputStream(InputStream in ){
		this.in=in;
	}
	
	
	public   int myRead() throws Exception{
		
		if(0==count){
			  count= in.read(buf);
			
			pos=0;
			byte b = buf[pos];
			count--;
			pos++;
			
			return  b &255;
			
		}else if(count>0){
			
			byte b = buf[pos];
			count--;
			pos++;
			
			return  b &255;
			
		}
				return -1;
		
		
	
		
	}
	
	public void myClose(){
		try {
			in.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
